'use strict';
/* Controllers */
define( function(){
	
	var IndexCtrl = ['$state','$scope', '$http', function($state, $scope, $http){
		$scope.new_topics = [];    //最新帖子
		
		$scope.tag = -1;   // 控制标签显示(-1:全部, -2:更多, 0~ :对应的类别)
		
		$http({	method:'post',
			url:"account"
		}).success(function(result){
			$scope.info = result.info;
			$scope.new_ = true;
		}).error(function(){
			alert("网络连接失败");
		});
		
		//跳转的状态
		var dest_state = $state.$current.name;
		if($state.$current.name.indexOf(".") < 0){
			dest_state = "index.topicAll";
		}
		
		// 按类别显示
		$scope.showCate = function(cate_id, tagIndex){
			$scope.tag = tagIndex;
			$state.go("index.topicAll", {cate_id: cate_id});
		};
		
		$state.go(dest_state);
	}];
	
	return {index: IndexCtrl};
});
